package cn.jn.lhm.netty.part06;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;

/**
 * @author lhm 2753914576@qq.com
 * @time 2023/10/29 - 18:07
 **/
public class TestUnpooled {
    public static void main(String[] args) {
        ByteBuf buf1 = ByteBufAllocator.DEFAULT.buffer(4);
        buf1.writeBytes(new byte[]{'a', 'b', 'c', 'd'});

        ByteBuf buf2 = ByteBufAllocator.DEFAULT.buffer(1);
        buf2.writeBytes(new byte[]{'e'});


        // 底层不会出现数据拷贝
        ByteBuf byteBuf = Unpooled.wrappedBuffer(buf1, buf2);

        System.out.println(byteBuf.getClass());
        System.out.println(ByteBufUtil.prettyHexDump(byteBuf));
    }
}
